package sqlanalysisgui.view.model.provider;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import sqlanalysisgui.view.model.ProjectInfo;

import com.cho.core.db.dao.TableDao;

public enum ProjectInfoModelProvider {
	INSTANCE;
	
	private List<ProjectInfo> projectInfos;
	
	private ProjectInfoModelProvider(){
		refreshProjectInfos();
	}

	public List<ProjectInfo> getProjectInfos() {
		refreshProjectInfos();
		return projectInfos;
	}
	
	public void refreshProjectInfos() {
		projectInfos = new ArrayList<ProjectInfo>();
		
		List<Map<String, String>> list = TableDao.selectProjectList();
		
		for (Map<String, String> map : list) {
			projectInfos.add(new ProjectInfo(map.get("PROJECT_NAME"), map.get("PROJECT_INFO"), map.get("PROJECT_PATH"), map.get("REG_DATE")));
		}
	}
}
